package apiday05homework;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        /*
        Scanner scan = new Scanner(System.in);
        FileOutputStream fos = new
                FileOutputStream("note1.txt",true);
        while (true) {
            System.out.println("请输入内容：");
            String  line = scan.nextLine();
            if ("exit".equalsIgnoreCase(line)) {
                break;
            }
            byte[] data= line.getBytes(StandardCharsets.UTF_8);
            fos.write(data);
        }
        System.out.println("数据写出完毕");
        fos.close();

         */
        Scanner scan = new Scanner(System.in);
        FileOutputStream fos = new FileOutputStream("note1.txt", true);
        while (true) {
            System.out.println("请输入内容：");
            String  line = scan.nextLine();
            if ("exit".equalsIgnoreCase(line)) {
                break;
            }
            byte[] data = line.getBytes(StandardCharsets.UTF_8);
            fos.write(data);
        }
        System.out.println("数据写出完毕");
        fos.close();
    }
}
